package androidchat.com.view;

import java.security.acl.Group;

import com.androidchat.R;
import com.androidchat.R.layout;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.database.Cursor;
import android.os.Build;
import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import androidchat.com.model.ClientChat;
import androidchat.com.sqlitedb.SqliteDB;
import androidchat.com.view.ManageFragment;

public class MainActivity extends Activity {
     RadioGroup rag;
     FragmentManager fragmentManager;  
     public static String account,nick;
   

	@SuppressLint("NewApi")
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mainactivity);
		fragmentManager = getFragmentManager();  
		rag=(RadioGroup)findViewById(R.id.radiogroup);
//		ClientChat.context=getApplicationContext();
//		ClientChat.test();
//		SqliteDB sd=new  SqliteDB(getApplicationContext());
//		System.out.println("success");
//	    String sql="insert into user(account,nickname) values('1234','zzzy')";
//	    String sql1="select * from user where account = ?";
//	    String[] data={"1234"};
//	    String a,n;
//	    sd.update(sql);
//	    Cursor cs=sd.query(sql1, data);
//	        while(cs.moveToNext()){
//	        	 a=cs.getString(0);
//	        	 n=cs.getString(1);
//	        	 System.out.println("account is "+a+"nickname is "+n);
//	        }
	       
		rag.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			
			@SuppressLint("NewApi")
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub
				FragmentTransaction transaction = fragmentManager.beginTransaction();  
				
                Fragment fragment = ManageFragment.getFangmentByIndex(checkedId);
                transaction.replace(R.id.content, fragment);  
                transaction.commit();  
				
			}
		});
		
		
	}
	

}
